import {IPoint} from "../metadata/PointData";

/**
 *  计算两点之间的欧几里得距离
 * @param point1  起始点
 * @param point2 目标点
 */
export const calculateDistance = (point1: IPoint, point2: IPoint):
    number => Math.sqrt(Math.pow(point2.x - point1.x, 2) + Math.pow(point2.y - point1.y, 2));

/**
 * 只使用 x 轴坐标计算两点之间的距离
 * @param point1 起始点
 * @param point2 目标点
 */
export const calculateDistanceXOnly = (point1: IPoint, point2: IPoint): number => Math.abs(point2.x - point1.x);